// class类
console.log('============== class类 ==============')

// 继承
class Person {

    constructor(name, gender) {
        this.name = name;
        this.gender = gender;
    }
    // 重写父类方法
    toStr() {
        console.log(`Person name:${this.name},gender:${this.gender}`);
    }
}

class User extends Person {
}

let user = new User('zs', 'man');
user.toStr();

class User2 extends Person {
    constructor(name, gender, addr) {
        // super调用父类构造器
        super(name, gender);
        this.addr = addr;
    }

    toStr() {
        super.toStr();
        console.log(`addr:${this.addr}`)
    }
}
let user2 = new User2('ls','women','china');
user2.toStr();